package xyz.xiangyushui.util.dataBase.client.command.seedCommand;

import xyz.xiangyushui.util.dataBase.client.command.Command;
import xyz.xiangyushui.util.dataBase.seed.Seeder;

public class SeedCommandExecutor {
	private final Seeder seeder;
	private final String seedCommand="seed";
	private final String emptyCommand="empty";
	private final String arg="table";
	
	public SeedCommandExecutor(){
		seeder=new Seeder();
	}
	
	/**
	 * execute a command
	 * @param c
	 */
	public void execute(Command c){
		if(isSpecificCommand(c, seedCommand)){
			seeder.seed(c.getArguments().get(arg));
		}else if(isSpecificCommand(c, emptyCommand)){
			seeder.empty(c.getArguments().get(arg));
		}else{
			throw new IllegalArgumentException("Invalid command:"+c.getCmd());
		}
	}
	
	private boolean isSpecificCommand(Command c,String s){
		return s.equals(c.getCmd());
	}
}
